// 场景管理
class SceneManager {
    constructor() {
        this.currentScene = null;
    }

    createGameScene() {
        scene("game", (opts = {}) => {
            // 清理现有游戏对象
            gameObjectManager.clear();
            
            // 创建背景
            this.createBackground();
            
            // 设置控制器
            this.setupControls();

            // 设置当前场景
            this.currentScene = curScene();
            
            if (opts.roomId) {
                console.log('Game scene initialized for room:', opts.roomId);
            }
        });

        // 创建初始场景
        scene("menu", () => {
            // 菜单场景不需要特殊处理
            console.log('Menu scene initialized');
        });
    }

    createBackground() {
        // 添加网格背景
        for (let i = 0; i < width(); i += CONFIG.GRID.SIZE) {
            add([
                rect(1, height()),
                pos(i, 0),
                color(...CONFIG.GRID.COLOR),
                fixed()
            ]);
        }
        for (let i = 0; i < height(); i += CONFIG.GRID.SIZE) {
            add([
                rect(width(), 1),
                pos(0, i),
                color(...CONFIG.GRID.COLOR),
                fixed()
            ]);
        }
    }

    setupControls() {
        controls.setupKeyboardControls();
    }

    getCurrentScene() {
        return curScene();
    }
}

const sceneManager = new SceneManager(); 